Home:ALL Converter>Why can I declare an array in a header file, but not a pointer?

Why can I declare an array in a header file, but not a pointer?

Ask Time:2012-06-22T04:44:57         Author:telandor

Json Formatter

I have a problem with my Consts.hpp file:

#pragma once
#include <stdafx.h>

namespace consts {
    const GLchar* TEXTURE_DIR = "../../blabla/"; // doesn't work
    const GLchar TEXTURE_DIR[14] = "../../blabla/"; // works
};

This file is added to the stdafx.h file. ColladaReader.cpp is the file where I access TEXTURE_DIR. Why does the pointer not work in the namespace? When accessing the constant I get this error:

 Error  5   error LNK2005: "char const * const consts::TEXTURE_DIR" (?TEXTURE_DIR@consts@@3PBDB) already defined in ColladaReader.obj   D:\Privat\code\openglearn\projects\ColladaReader\stdafx.obj

Author:telandor,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11146447/why-can-i-declare-an-array-in-a-header-file-but-not-a-pointer
yy